package com.j177.cloud.controller;

import com.j177.cloud.dto.UserDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

/**
 * @Author:LuJiaHong
 * @Date:2020/11/30~16:37:28
 * @Version 1.0
 */
@RestController
public class UserController {

    @Autowired
    private RestTemplate restTemplate;

    @GetMapping("loginByStr")
    public String loginByStr(String userName,String passWord){
        String result = restTemplate.getForEntity("http://localhost:8080/loginByStr/"+userName+"/"+passWord,String.class).getBody();
        System.out.println(result);
        return "ok,str";
    }

    @GetMapping("loginByObj")
    public String loginByObj(String userName,String passWord){
        UserDto userDto = new UserDto(userName,passWord);
        String result = restTemplate.postForEntity("http://localhost:8080/loginByObj",userDto,String.class).getBody();
        System.out.println(result);
        return "ok,obj";
    }
}
